.TH std::clearerr 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::clearerr \- std::clearerr

.SH Synopsis
   Defined in header <cstdio>
   void clearerr( std::FILE* stream );

   Resets the error flags and the EOF indicator for the given file stream.

.SH Parameters

   stream - the file to reset the error flags for

.SH Return value

   \fI(none)\fP

.SH Example


// Run this code

 #include <cassert>
 #include <cstdio>

 int main()
 {
     std::FILE* tmpf = std::tmpfile();
     std::fputs("cppreference.com\\n", tmpf);
     std::rewind(tmpf);

     for (int ch; (ch = std::fgetc(tmpf)) != EOF; std::putchar(ch)) { }

     assert(std::feof(tmpf)); // the loop is expected to terminate by EOF
     std::puts("End of file reached");

     std::clearerr(tmpf); // clear EOF

     std::puts(std::feof(tmpf) ? "EOF indicator set"
                               : "EOF indicator cleared");
 }

.SH Output:

 cppreference.com
 End of file reached
 EOF indicator cleared

.SH See also

   feof   checks for the end-of-file
          \fI(function)\fP
   perror displays a character string corresponding of the current error to stderr
          \fI(function)\fP
   ferror checks for a file error
          \fI(function)\fP
   C documentation for
   clearerr
